package com.itqian.system.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.HashSet;

/**
 * @author shishuqian
 * date 2022/3/26
 * time 19:15
 **/
public class RoleUtil {

    /**
     *
     * @author shishuqian
     * @desc  返回给用户添加新权限后的role字符串
     */
    public static String addRole(String nowRole,String newRole){
        String[] s = nowRole.split("_");
        HashSet<String> roleSet = new HashSet<>();
        roleSet.addAll(Arrays.asList(s));
        //给用户添加新身份
        roleSet.add(newRole);
        String[] strings = roleSet.toArray(new String[roleSet.size()]);
        return StringUtils.join(strings, "_");
    }


}
